<?php 
if(empty($aususrpinverid))
{
	echo 'login';
	exit;	
}
$db = phpclone($dbObj);
$sql="select generatedate from usr_registrationcode where generatored='$aususrpinverid' order by generatedate desc limit 1";

$result=$db->executeQuery($sql);

if((time()-$result[0]['generatedate'])<60)
{
	echo 'often';
	exit;
}
$chars=array('a','b','c','d','e','f','g','h','i','g','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0');
$len=count($chars)-1;
$code='';

$sql="select * from usr_registrationcode where registrationid='$code'";
do{
	for($i=0; $i<16; $i++)
	{
		$code.=$chars[mt_rand(0,$len)];	
	}
}while($db->getQueryNum("select * from usr_registrationcode where registrationid=".$code)>0);

$sql="insert into usr_registrationcode(registrationid,generatored,generatedate) values('$code','$aususrpinverid','".time()."')";
//echo $sql;
$rs=$db->executeBasicQuery($sql);
if($rs)
{
	echo $code;	
}
else
{
	echo 'failure';	
}

?>